// pages/search/index.js
var app = getApp();
var rootDocment = app.globalData.postUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hiddenLoading: false,
    inputVal:"",
    hotList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //初始化
    var that = this;
    that.getHotListData();
  },

  //获取热搜词
  getHotListData: function () {
    var that = this;
    wx.request({
      url: rootDocment + '/api/comm_get/getHotKeys',
      data: { },
      method: 'GET',
      header: {},
      success: function (res) {
        that.setData({
          hotList: res.data,
          hiddenLoading: true
        });
        
      }
    })
  },

  inputTyping: function (e) {
    this.setData({
      inputVal: e.detail.value
    });
  },

  goSearch: function () {
    var key = this.data.inputVal.replace(/\s+/g, "");
    if (key == '') {
      wx.showToast({
        title: '关键词为空！',
        icon: 'none'
      })
    }
    else {
      app.redirect('search/list', 'key=' + key)
    }
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

})